<template>
  <view class="w100p common_wrap no-bg">
    <CommonHeader :title="$t('参与订单')"></CommonHeader>

    <view class="w100p pr list_block">
      <scroll-view scroll-y class="scroll-Y">
        <view class="scroll-wrapper">
          <view style="height: 16rpx;"></view>
          <view class="top-base-section">
            <swiper indicator-dots autoplay circular indicator-color="#9B969A" indicator-active-color="#fff"
              class="swiper-top swiper">
              <swiper-item v-if="!!currentVideo">
                <view class="pr video_wrap">
                  <video id="myVideo" class="w100p  palyxxx" :src="currentVideo" :show-center-play-btn="true"
                    object-fit="cover" play-btn-position="center" :controls="true" :autoplay="isAdroid ? true : false" muted
                   >
                  </video>
                  <view class="video-wrapxx">
                        <image :src="get(purchaseInfo, 'purchaseInfo.productImgUrls').split(',')[0]" 
                        mode="aspectFill"></image>
                  </view>
                  <cover-view  class="pa play_wrap" @click="playsHeader(currentVideo,'first_video')">
                    <view class="icon_wrap">
                      <u-icon name="play-right-fill" color="#fff" size="46"></u-icon>
                    </view>
                  </cover-view>
                </view>
            </swiper-item>
              <swiper-item class="swiper-item-li" v-for="(item, index) in get(purchaseInfo, 'purchaseInfo.productImgUrls').split(',')" :key="index">
                <image :src="getImageUrl(item)" mode="aspectFill" />
              </swiper-item>
            </swiper>
            <!-- 采购信息 -->
            <view class="caigou-info">
              <view class="title">
                <view class="name">{{$t('采购信息')}}</view>
                <!-- <view class="time">结束倒计时：{{ timeString }}</view> -->
              </view>
              <view class="list">
                <view class="txt">{{$t('需求商品')}}</view>
                <view class="txtContent">{{get(purchaseInfo, `purchaseInfo.${plangJava('productName')}`)}}</view>
              </view>
             <!-- <view class="list">
                <view class="txt">期望单价</view>
                <view class="txt">100000元</view>
              </view> -->
              <!-- <view class="list">
                <view class="txt">期望单价</view>
                <view class="txt">起重机</view>
              </view> -->
              <view class="list">
                <view class="txt">{{$t('目的地')}}</view>
                <view class="txtContent">{{get(purchaseInfo, `purchaseInfo.${plangJava('destination')}`)}}</view>
              </view>
              <view class="list">
                <view class="txt">{{$t('需求数量')}}</view>
                <view class="txtContent">{{ purchaseInfo.purchaseInfo.amount }} {{ 
               get(purchaseInfo, `purchaseInfo.${plangJava('unit')}`)
              }}</view>
              </view>
            </view>
          </view>
          <!-- 基础信息 -->
          <view class="base-info" @click="goPerson">
            <view class="left-avatar">
              <view class="avatar-w">
                <view class="avatar">
                  <image :src="getImageUrl(purchaseInfo.avatar)" mode="aspectFill"></image>
                </view>
                <view class="country">
					<flag :country="purchaseInfo.country"></flag>
                  <!-- <image src="/static/caigou/ru.png" mode="aspectFill"></image> -->
                </view>
              </view>
              <view class="desc-avatar">
                <view class="name ellipsis_one">{{purchaseInfo[plangJava('username')]}}</view>
               <view class="vip-leval">
                 <view class="circle">
                   <image v-if="purchaseInfo.vipLevel == 0" src="@/static/detail/vip_1.png" mode="scaleToFill" />
                   <image v-if="purchaseInfo.vipLevel == 1" src="@/static/detail/vip_2.png" mode="scaleToFill" />
                   <image v-if="purchaseInfo.vipLevel == 2" src="@/static/detail/vip_3.png" mode="scaleToFill" />
                   <image v-if="purchaseInfo.vipLevel == 3" src="@/static/detail/vip_4.png" mode="scaleToFill" />
                 </view>
                 <text>VIP</text>
               </view>
                <!-- <view v-else-if="purchaseInfo.vipLevel == 1" class="vip-leval">
                	<view class="circle">
                	  <image src="/static/detail/vip_1.png" mode="scaleToFill" />
                	</view>
                	<text>黄金会员</text>
                </view>
                <view v-else-if="purchaseInfo.vipLevel == 2" class="vip-leval">
                	<view class="circle">
                	  <image src="/static/detail/vip_1.png" mode="scaleToFill" />
                	</view>
                	<text>铂金会员</text>
                </view>
                <view v-else-if="purchaseInfo.vipLevel == 3" class="vip-leval">
                	<view class="circle">
                	  <image src="/static/detail/vip_1.png" mode="scaleToFill" />
                	</view>
                	<text>钻石会员</text>
                </view> -->
              </view>
            </view>
            <!-- 单数 -->
            <view class="right-numwrap">
              <view class="li">
                <view class="txt" :style="langR =='zh'? 'max-width: 120rpx;':'max-width: 120rpx;font-size:24rpx;'">{{$t('发布采购')}}</view>
                <view class="num">{{purchaseInfo.totalPurchase}}</view>
              </view>
              <view class="li">
                <view class="txt" :style="langR =='zh'? 'max-width: 120rpx;':'max-width: 120rpx;font-size:24rpx;'">{{$t('成交单数')}}</view>
                <view class="num">{{purchaseInfo.totalDeal}}</view>
              </view>
              <view class="li">
                <view class="txt" :style="langR =='zh'? 'max-width: 120rpx;':'max-width: 120rpx;font-size:24rpx;'">{{$t('成交率')}}</view>
                <view class="num">{{ ((purchaseInfo.dealRate || 0) * 100).toFixed(0) }}%</view>
              </view>
            </view>


          </view>
          <view class="reprot">
            <block v-if="langR == 'zh'">{{$t('已有')}}</block>{{purchaseInfo.participateCount}}{{$t('人感兴趣并参与报价')}}</view>

          <!-- 底部表单 -->
          <view class="bottom-form">

            <view class="box-same">
              <view class="title-biao" @click="onCurrentTypeOf">
                <view class="can">{{$t('参与信息')}}  </view>
                <view class="right-qiehuan">
                  <text>{{ currentType == 1 ? $t('请选择已有商品') : $t('填写商品信息') }}</text>
                  <image src="/static/caigou/xiangyouce.png"></image>
                </view>
              </view>

              <template v-if="currentType == 1">
                <view class="inp-li">
                  <view class="title">{{$t('商品名称')}}<text>*</text></view>
                  <view class="inp">
                    <input type="text" :placeholder="$t('输入商品名称')" v-model="faQuotation.productName" placeholder-class="input-placeholder-cai" />
                  </view>
					<p v-if="!faQuotation.productName && validateFlag" class="fz22 mt-5" style="color: #FF0000;">{{$t('请输入商品名称')}}</p>
                </view>
                <view class="inp-li">
                  <view class="title">{{$t('商品品牌')}}<text>*</text></view>
                  <view class="inp">
                    <input type="text" :placeholder="$t('输入商品品牌')" v-model="faQuotation.productBrand" placeholder-class="input-placeholder-cai" />
                  </view>
					<p v-if="!faQuotation.productBrand && validateFlag" class="fz22 mt-5" style="color: #FF0000;">{{$t('请输入商品品牌')}}</p>
                </view>
              </template>

              <template v-if="currentType == 2">
                <view class="inp-li">
                  <view class="title">{{$t('已有商品链接')}}<text>*</text></view>
                  <!-- 商品选择 -->
                  <view class="goods-wrap">
                    <view class="inp-filter"  @click="showGood = true">
                      <text> {{ $t('请选择已有商品') }}</text>
                      <image src="/static/caigou/xiala.png"></image>
                    </view>
                    <!-- 商品列表 -->
                    <view class="list-wraps" v-if="shopProduct.length > 0 && currentIndex !== null">
                      <view class="list">
                        <!-- <image :src="shopProduct[currentIndex].pics" mode="aspectFill" /> -->
						          <image v-if="shopProduct[currentIndex].pics" :src="getImageUrl(getOneImg(shopProduct[currentIndex].pics))" mode="aspectFill" class="imgx"/>
                        <view class="right-section">
                          <view class="name ellipsis_two">
                            {{shopProduct[currentIndex][plangJava('name')]}}
                          </view>
                          <view class="price">
                            <text>￥</text>{{shopProduct[currentIndex].sellPrice}}
                          </view>
                        </view>
                      </view>
                    </view>
                  </view>
				  <p v-if="shopProduct.length == 0 && validateFlag" class="fz22 mt-5" style="color: #FF0000;">{{$t('请选择商品链接')}}</p>
                </view>
              </template>



              <view class="inp-li">
                <view class="title">{{$t('商品报价（总价）')}}<text>*</text></view>
                <view class="inp">
                  <input type="text" :placeholder="$t('请输入商品报价（总价）')" placeholder-class="input-placeholder-cai" v-model="faQuotation.price" />
                </view>
				<p v-if="!faQuotation.price && validateFlag" class="fz22 mt-5" style="color: #FF0000;">{{$t('请输入商品报价')}}</p>
				<p v-if="!priceTest && faQuotation.price" class="fz22 mt-5" style="color: #FF0000;">{{$t('只能输入数字')}}</p>
              </view>

              <view class="inp-li" @click="isShowUnit = true">
                <view class="title">{{$t('报价单位')}}<text>*</text></view>
                <view class="inp" >
				        	<input type="text" :disabled="true" :placeholder="$t('请选择报价单位')" placeholder-class="input-placeholder-cai" v-model="priceUnit" />
                </view>
			          	<p v-if="!priceUnit && validateFlag" class="fz22 mt-5" style="color: #FF0000;">{{$t('请选择报价单位')}}</p>
              </view>
             <!-- <view class="inp-li">
                <view class="title">{{$t('商品')}}报价（单价）<text>*</text></view>
                <view class="inp">
                  <input type="text" placeholder="输入产品单价（卢布）（实时汇率 1元=100卢布）"
                    placeholder-class="input-placeholder-cai" v-model="faQuotation.ruble" />
                </view>
				<p v-if="!faQuotation.ruble && validateFlag" class="fz22 mt-5" style="color: #FF0000;">请输入{{$t('商品')}}报价</p>
              </view> -->
              <view class="inp-li">
                <view class="title">{{$t('发货地址')}}<text>*</text></view>
                <view class="inp">
                  <input type="text" :placeholder="$t('请输入发货地址')" placeholder-class="input-placeholder-cai" v-model="faQuotation.address" />
                </view>
				<p v-if="!faQuotation.address && validateFlag" class="fz22 mt-5" style="color: #FF0000;">{{$t('请输入发货地址')}}</p>
              </view>

              <!-- 是否现货 -->
              <view class="inp-li">
                <view class="title">{{$t('是否现货')}}<text>*</text></view>
                <view class="selects">
                  <view class="select" :class="{active: faQuotation.isInStock == 1 }" @click="faQuotation.isInStock=1">{{$t('是')}}</view>
                  <view class="select" :class="{active: faQuotation.isInStock == 0 }" @click="faQuotation.isInStock=0">{{$t('否')}}</view>
                </view>
				<p v-if="!faQuotation.isInStock && validateFlag" class="fz22 mt-5" style="color: #FF0000;">{{$t('请选择是否现货')}} </p>
              </view>

              <view class="inp-li">
                <view class="title">{{$t('生产周期（天）')}}<text>*</text></view>
                <view class="inp">
                  <input type="text" :placeholder="$t('请输入生产周期')" placeholder-class="input-placeholder-cai" v-model="faQuotation.productDuration"/>
                </view>
				<p v-if="!faQuotation.productDuration && validateFlag" class="fz22 mt-5" style="color: #FF0000;">{{$t('请输入生产周期')}}</p>
				<p v-if="!dayTest && faQuotation.productDuration" class="fz22 mt-5" style="color: #FF0000;">{{$t('只能输入数字')}}</p>
              </view>

              <!-- 是否含运费 -->
              <!-- <view class="inp-li">
                <view class="title">{{$t('是')}}{{$t('否')}}含运费<text>*</text></view>
                <view class="selects">
                  <view class="select active">{{$t('是')}}</view>
                  <view class="select">{{$t('否')}}</view>
                </view>
              </view> -->

              <!-- 采购简介 -->
              <view class="box-same caigou-jianjie">
                <view class="title">{{$t('商品简介')}}<text class="require">*</text></view>
                <view class="textarea">
                  <textarea :placeholder="$t('请输入产品简介')" placeholder-class="input-placeholder-cai" v-model="faQuotation.description" style="font-size: 28rpx;"></textarea>
				  <p class="text-888 fz24" style="position: absolute; bottom: 10rpx; right: 20rpx;"> {{ remainingService }} </p>
                </view>
				<p v-if="!faQuotation.description && validateFlag" class="fz22 mt-5" style="color: #FF0000;">{{$t('请输入产品简介')}}</p>
              </view>

            </view>

            <!-- 自定义商品参数 -->
            <view class="box-same" v-if="false">
              <!-- 添加自定义参数 -->
              <view class="prams-cl">
                <view class="ul">
                  <view class="li" v-for="(item, index) in paramsList" :key="index">
                    <view class="canshu">
                      <input type="text" :placeholder="$t('自定义参数名称')" v-model="item.name"
                        placeholder-class="input-placeholder-cai" style="font-size: 28rpx;"/>
                    </view>
                    <view class="canshu canshu-ri">
                      <input type="text" :placeholder="$t('输入自定义参数')" style="font-size: 28rpx;" v-model="item.value"
                        placeholder-class="input-placeholder-cai" />
                    </view>
                    <view class="delete" @click="onDeleteMain(index)">-</view>
                  </view>
                </view>
                <view class="btn" @click="addParams">
                  {{$t('添加自定义参数')}}
                  <image src="/static/caigou/add.png"></image>
                </view>
                <view class="tips">{{$t('最多添加5条自定义参数')}}</view>
              </view>

            </view>

            <!-- 图片上传 -->
            <view class="box-same upload-wrapper">
              <template v-if="currentType == 1">
               <view class="upload-li">
                 <view class="title">{{$t('上传')}}{{$t('商品图片')}}<text class="require">*</text><text class="yaoqiu">{{$t('支持jpeg、jpg、png (大小7m内)')}}</text></view>
                 <view class="uploads">
                   <view class="img" v-for="item,index in options.productImgUrls" :key="index" @click="onPreview(item.fullurl)">
                     <image
                       :src="item.fullurl"
                       mode="aspectFill"
                     />
						<view class="delete" @click.stop="onDelete(index, 'productImgUrls')">
							<view class="lien"></view>
						</view>
                   </view>
                   <view class="img" @click="onUpload({ type: 'image', size: 7, count: 3 })" v-if="options.productImgUrls.length<3">
                     <image
                       src="/static/caigou/upload.png"
                     />
                   </view>
                 </view>
               	<p v-if="options.productImgUrls.length == 0 && validateFlag" class="fz22 mt-5" style="color: #FF0000;">{{$t('请上传商品图片')}}</p>
               </view>
                <view class="upload-li">
                  <view class="title">{{$t('上传商品视频')}}<text class="yaoqiu">{{$t('支持mp4、rmvb、AVI (大小35m内)')}}</text></view>
                  <view class="uploads">
                    <view class="img zhan" v-for="item,index in options.productVideoUrls" :key="index" @click="onPreviewVideo(item.fullurl)" style="background-color: antiquewhite;">
                      <image
                        :src="item.fullurl"
                        mode="aspectFill"
                      />
                      <!-- <image :src="options.productImgUrls[0].fullurl" mode="aspectFill" style="background-color: azure; position: absolute;left: 0;" /> -->
                      <image src="/static/icon/play.png" mode="aspectFill" class="paly"></image>
                      <view class="delete" @click.stop="onDelete(index, 'productVideoUrls')">
                        <view class="lien"></view>
                      </view>
                    </view>
                    <view class="img" @click.stop="onUpload({ type: 'video', size: 35, count: 1 })" v-if="options.productVideoUrls.length<1">
                      <image
                        src="/static/caigou/upload.png"
                      />
                    </view>
                  </view>
                </view>
              </template>

              <view class="upload-li">
                <view class="title">{{$t('上传商品其他文件')}}<text class="yaoqiu">{{$t('支持jpeg、jpg、png (大小7m内)')}}</text></view>
                <view class="uploads">
                  <view class="img" v-for="item,index in options.productOtherFileUrls" :key="index" @click="onPreview(item.fullurl)">
                    <image
                      :src="item.fullurl"
                      mode="aspectFill"
                    />
              				<view class="delete" @click.stop="onDelete(index, 'productOtherFileUrls')">
              					<view class="lien"></view>
              				</view>
                  </view>
                  <view class="img" @click="onUpload({ type: 'image', size: 7, count: 3 }, 'other')" v-if="options.productOtherFileUrls.length<3">
                    <image
                      src="/static/caigou/upload.png"
                    />
                  </view>
                </view>
              </view>
			  
			   <!-- <view class="upload-li">
			     <view class="title">{{$t('上传收款账号图片')}}<text class="require">*</text><text class="yaoqiu">{{$t('支持jpeg、jpg、png (大小7m内)')}}</text></view>
			     <view class="uploads">
			       <view class="img" v-for="item,index in options.accountNumberImg" :key="index" @click="onPreview(item.fullurl)">
			         <image
			           :src="item.fullurl"
			           mode="aspectFill"
			         />
			  						<view class="delete" @click.stop="onDelete(index, 'accountNumberImg')">
			  							<view class="lien"></view>
			  						</view>
			       </view>
			       <view class="img" @click="onUpload({ type: 'image', size: 7, count: 3 }, 'number')" v-if="options.accountNumberImg.length<3">
			         <image
			           src="/static/caigou/upload.png"
			         />
			       </view>
			     </view>
			   	<p v-if="options.accountNumberImg.length == 0 && validateFlag" class="fz22 mt-5" style="color: #FF0000;">{{$t('请上传图片')}}</p>
			   </view> -->
            </view>

          </view>
          <view style="height: 18rpx;"></view>

        </view>

      </scroll-view>
    </view>

    <!-- 取消 -->
    <view class="btn-wrap" >
      <button :disabled="btnDis" class="btn green" @click="onSubmit">{{$t('提交报价')}}</button>
    </view>


    <!-- 单位选择 -->
    <u-select :confirm-text="$t('确定')" :cancel-text="$t('取消')" v-model="isShowUnit" :list="currencyList" @confirm="confirmUnit" value-name="symbol" label-name="nameSym"></u-select>
    <!-- 选择已有商品 -->
    <u-popup v-model="showGood" mode="bottom" :safe-area-inset-bottom="true" border-radius="24" :closeable="false"
      close-icon="close-circle" close-icon-size="44" @close="closeGood">
      <view class="popup-wrapper" >
        <scroll-view scroll-y style="height: 60vh;">
          <view class="list-wraps-uppu">
            <view v-show="shopProduct.length > 0" :class="['list', index == currentIndex && 'active']" v-for="(item, index) in shopProduct" :key="index" @click="onGoodConfirm(index, item)">
              <image v-if="item.pics" :src="getImageUrl(getOneImg(item.pics))" mode="aspectFill" class="imgx"/>
              <view class="right-section">
                <view class="name ellipsis_two">
                  {{item[plangJava('name')]}}
                </view>
                <view class="price">
                  <text>￥</text>{{item.sellPrice}}
                </view>
              </view>
              <image
                v-if="index == currentIndex"
                class="option"
                :src="'https://gluz-oss.oss-cn-beijing.aliyuncs.com/'+item.pics"
              />
            </view>
			<view v-show="shopProduct.length == 0" class="">
				<p class="fz30 text-888" style="text-align: center;">{{$t('暂无商品')}}</p>
			</view>
          </view>
        </scroll-view>

        <view class="confirm" @click="closeGood">{{$t('确定')}}</view>
      </view>
    </u-popup>
    <u-popup v-model="previewVideoIsShow" mode="center">
			<div class="center flex-col">
				<video style="width: 700rpx;" :src="previewVideoUrl" controls></video>
				<div class="btn bg-primary rounded-50 fz28 text-white w-200 h-80 center mt-20 mb-20"
					@click="previewVideoIsShow = false">{{$t('关闭')}}</div>
			</div>
		</u-popup>
    <!-- 播放视频 -->
    <uni-popup ref="popupVideo" type="center" background-color="#000" mask-background-color="#000" class="popvexxx">
      <view class="wrapper-video">
        <video id="mainVideo" :src="playVideo" :show-center-play-btn="true" object-fit="cover"
          play-btn-position="center" :controls="true" :autoplay="isAdroid ? true : false" class="video-main" :show-fullscreen-btn="false">
        </video>
      </view>
    </uni-popup>
  </view>
</template>


<script>
import CommonHeader from "@/pages/components/common-header.vue";
import countdownMixin from '@/assets/countDownMixin';
import {purchaseInfoGet,shopProductList,faQuotationSave, faQuotationGet } from "@/api/caigou.js"
  import { uploadFile, chooseFile } from '@/assets/public.js';
import currency from '@/utils/currency'
export default {
  mixins: [countdownMixin],
  components: {
    CommonHeader
  }, 
  data() {
    return {
      paramsList: [],
      previewVideoIsShow:false,
      previewVideoUrl:'',
	    currencyList: currency.currencyList,
      listUnits: [
        {
          value: '1',
          label: this.$t('个')
        },
        {
          value: '2',
          label: this.$t('台')
        },
      ],
      isShowUnit: false,
      currentType: 2, // 1 填写商品信息 2 选择已有商品
      showGood: false,
	  validateFlag: false,
      currentIndex: 0,
	  btnDis: false,
	  priceTest: false,
	  dayTest: false,
	  purchaseInfo:{},
	  options:{
	  	productImgUrls:[],
	  	productVideoUrls:[],
	  	productOtherFileUrls:[],
		  accountNumberImg: []
	  },
	  priceUnit: '',
	  faQuotation:{
		  id:"",  //报价信息主键ID，若该ID赋值，则表示更新报价信息，若该ID为空，则表示新增报价信息
		  userId:"", //报价人的用户ID
		  purchaseInfoId:"",  //采购信息ID
		  productName:"",  //商品名称
		  productNameRu:"",  //商品名称（俄语）
		  productBrand:"",  //商品品牌
		  productBrandRu:"",  //商品品牌（俄语）
		  price:"",  //价格
		  currency: '',
		  ruble:"",  //价格-卢布
		  address:"",  //发货地址
		  addressRu:"",  //发货地址（俄语）
		  isInStock:1,  //是否现货，0：否，1：是
		  productDuration:"",  //生产周期（天）
		  description:"", //商品简介
		  descriptionRu:"",  //商品简介（俄语）
		  customizeParam:{}, //自定义参数，用json格式保存，例如：{"A":"a","B":"b"}
		  customizeParamRu:{},  //自定义参数（俄语），用json格式保存，例如：{"A":"a","B":"b"}
		  productImgUrls:"",  //商品图片，多张图片中间用，拼接
		  productVideoUrls:"",  //商品视频，多个视频中间用，拼接
		  productOtherFileUrls:"",  //商品其他文件，多个文件中间用，拼接
		  accountNumberImg: ''  // 收款账号图片地址
	  },
	  shopProduct:[],
	  maxLength: 140,
	  IMAGE_URL: 'https://gluz-oss.oss-cn-beijing.aliyuncs.com/',
	  qutationId: '',
	  faQuotationObj: {},
    videos:null,
    playVideo:'',
		isAdroid: false,

    }
  },
  onLoad(options){
    console.log(options,'sjsjsjjslllllll')
    this.videos = uni.createVideoContext('myVideo');
	  this.getPurchaseInfo(options.id)
	  this.getshopProductList(options.id)
	  if (options.qutationId) {
		  this.qutationId = options.qutationId
		  console.log('this.qutationId---', this.qutationId)
	  }
    const systemInfo = uni.getSystemInfoSync();
    this.isAdroid = systemInfo.platform === 'android';
  },
  computed: {
    remainingService() {
      return this.maxLength - this.faQuotation.description.length;
    },
  },
  watch: {
	  'faQuotation.price': {
	  	handler(val) {
	  		console.log(this.faQuotation.price)
	  		this.priceTest = (/^[-+]?\d*\.?\d+$/).test(this.faQuotation.price)
			console.log('this.priceTest-', this.priceTest)
	  	},
	  },
	'faQuotation.productDuration': {
		handler(val) {
			console.log(this.faQuotation.productDuration)
			this.dayTest = (/^[0-9]+$/).test(this.faQuotation.productDuration)
				console.log('this.dayTest', this.dayTest)
		},
	}
	  
  },
  onShow() {
    this.startCountDown(3000 * 1000);
  },
  methods: {
      goPerson() {
        if (this.purchaseInfo.identityType == 0) {
          uni.navigateTo({
            url: `/pages/details/merchantDetail?bid=${this.purchaseInfo.shopId}`,
            webview: 'zWebViewShop'
          })
        } else {
          uni.navigateTo({
            url: `/pages/myPersonPage/index?targetUserId=${this.purchaseInfo.purchaseInfo.publishUserId}`,
            webview: 'zWebView'
          })
        }
      },

      // 播放头部视频
      playsHeader(video,e) {
          console.log('video--', video,e)
            // 判断安卓
            const systemInfo = uni.getSystemInfoSync();
            // 判断是否为 Android 系统
            if (systemInfo.platform === 'android') {
              this.playVideo = video;
              this.$refs.popupVideo.open()
              return;
            }
            this.$nextTick(() => {
              if(e == 'first_video'){
                this.videos.play();
                this.videos.requestFullScreen();
              }
          
            })
    },

	  getOneImg(str) {
		  console.log('getOneImg---', str)
		  return str.split(',')[0]
	  },
	//获取当前用户的商品信息列表
	getshopProductList(iddd){
		shopProductList({"userId":uni.getStorageSync('user_id')}).then((res)=>{
			if(res.code==0){
				this.shopProduct = res.data
        console.log( this.shopProduct,'999999999999999999')
        if (this.shopProduct.length == 0) {
          this.currentType = 1;
        }

        this.faQuotation.price = res.data[0].sellPrice
        let  pics = this.shopProduct[0].pics?.split(',')
        let  videos = this.shopProduct[0].videoUrl?.split(',')
        this.options.productImgUrls = pics.map((img, index) => ({
          fullurl: img
        }));
        this.faQuotation.productBrand = res.data[0][this.plangJava('brand')]
        this.faQuotation.productName = res.data[0][this.plangJava('name')]
      
        this.faQuotation.description = res.data[0].detail
        this.options.productVideoUrls = videos.map((item, index) => ({
          fullurl: item
        }));
	      this.getFaQuotationGet({'purchaseInfoId':iddd,'quotationUserId':uni.getStorageSync('user_id')})

        console.log( this.options.productImgUrls,'999999999999999999')
      
      
			}
		})
	},
	//获取详情
	getPurchaseInfo(id){
		purchaseInfoGet({'purchaseInfoId':id}).then((res)=>{
			if(res.code==0){
				this.purchaseInfo=res.data
         this.currentVideo = res.data.purchaseInfo.productVideoUrls || ''
         console.log(this.currentVideo,'999999999999999999999')
			}
		})
	},
	// 上传视频和图片
	async onUpload({
		type,
		size,
		count
	}, keyx) {
		console.log('0000')
		let res = await uploadFile(await chooseFile({
			type,
			size,
			count,
		}))
		if (keyx == 'other') {
			console.log('res--111111111other', res)
			this.options.productOtherFileUrls.push(res);
		} else if (keyx == 'number') {
			console.log('res--', res) 
			this.options.accountNumberImg.push(res);
		} else {
			if (type == 'image') {
				console.log('res--', res)
				this.options.productImgUrls.push(res);
			}
			if (type == 'video') {
					console.log('res--', res)
				this.options.productVideoUrls = [res];
			}
		}
		
	},
	onDeleteMain(index) {
		this.paramsList.splice(index, 1)
	},
	// 删除图片
	onDelete(index, arr) {
	  this.options[arr].splice(index, 1)
	  console.log(this.options[arr], ' this[arr]')
	  this.$forceUpdate();
	},
	onPreview(current) {
		uni.previewImage({
			current,
			urls: [current],
			
		})
	},
	// 预览视频
	onPreviewVideo(url) {
    console.log(url,12333333)
		this.previewVideoUrl = url;
    this.previewVideoIsShow = true
		// this.$nextTick(() => {
		// 	this.$refs.popupVideo.open()
		// })
	},
    onCurrentTypeOf() {
      if (this.shopProduct.length == 0) {
        this.currentType = 1;
        uni.showToast({
          title: this.$t('暂无商品'),
          icon: 'none'
        })
        return;
      }
      this.currentType = this.currentType == 1 ? 2 : 1;
      this.faQuotation.price = ''
      this.options.productImgUrls = [];
      this.options.productOtherFileUrls = [];
      this.options.accountNumberImg = [];
      this.faQuotation.productBrand = '';
      this.faQuotation.productName = '';
      this.faQuotation.productNameRu = '';
      this.faQuotation.productBrandRu = '';
      this.faQuotation.price = '';
      this.faQuotation.currency = '';
      this.faQuotation.ruble = '';
      this.faQuotation.address = '';
      this.faQuotation.addressRu = '';
      this.faQuotation.isInStock = 1;
      this.faQuotation.productDuration = '';
      this.faQuotation.description = '';
      this.faQuotation.descriptionRu = '';
      this.faQuotation.customizeParam = {};
      this.faQuotation.customizeParamRu = {};
      this.faQuotation.productImgUrls = '';
      this.faQuotation.productVideoUrls = '';
      this.faQuotation.productOtherFileUrls = '';
      this.faQuotation.accountNumberImg = '';
      this.priceUnit = '';
      this.paramsList = [];
      this.currentIndex = null;



      
      this.faQuotation.description = '';
      this.options.productVideoUrls = [];

    },
    onGoodConfirm(index, item) {
		// console.log('item0000', item)
      this.currentIndex = index;
	  // this.faQuotation.productName = item.
    },
    closeGood() {
      this.showGood = false;
      console.log(this.shopProduct.length,'ffffffffffff')
	  if(this.shopProduct.length > 0) {
		  this.faQuotation.productName = this.shopProduct[this.currentIndex][this.plangJava('name')]
      this.faQuotation.price =this.shopProduct[this.currentIndex].sellPrice 
		  this.faQuotation.productBrand = this.shopProduct[this.currentIndex][this.plangJava('brand')]
      let  pics = this.shopProduct[this.currentIndex].pics?.split(',')
        let  videos = this.shopProduct[this.currentIndex].videoUrl?.split(',')
        this.options.productImgUrls = pics.map((img, index) => ({
          fullurl: img
        }));
      // this.priceUnit =  this.shopProduct[this.currentIndex][this.plangJava('unit')]
      this.faQuotation.description = this.shopProduct[this.currentIndex].detail
      this.options.productVideoUrls = videos.map((item, index) => ({
          fullurl: item
        }));
	  }
    },
    // onDelete(index) {
    //   this.paramsList.splice(index, 1)
    // },
    addParams() {
      if (this.paramsList.length == 5) {
        uni.showToast({
          title: this.$t('最多提交5条自定义参数'),
          icon: 'none',
        })
        return;
      }
      this.paramsList.push({
        name: '',
        value: '',
      })
    },
	//查询某个采购寻单的参与报价信息
	getFaQuotationGet(data){
		faQuotationGet(data).then((res)=>{
			if(res.code==0){
				this.faQuotationObj = res.data
				this.faQuotation = Object.assign(res.data.faQuotation)
        this.priceUnit = res.data.faQuotation.currency

        this.currentType = 1 || res.data.faQuotation.isOptionGood;
        if (this.currentType == 2) {
          // let index = this.shopProduct.findIndex((ele)=>{
          //   return ele.id == 
          // })
          // this.currentIndex = index;
        }

        let  pics = res.data.faQuotation.productImgUrls?.split(',')
        let  videos = [];
        if (res.data.faQuotation.productVideoUrls) {
          videos = res.data.faQuotation.productVideoUrls?.split(',')
        }

        this.options.productImgUrls = pics.map((img, index) => ({
          fullurl: img
        }));
        console.log(videos,'videosvideosvideosvideos')
        this.options.productVideoUrls = videos.map((item, index) => ({
          fullurl: item
        }));

        let picsOther = [];
        if (res.data.faQuotation.productOtherFileUrls) {
          picsOther = res.data.faQuotation.productOtherFileUrls?.split(',')
        }

        this.options.productOtherFileUrls = picsOther.map((img, index) => ({
          fullurl: img
        }));

        console.log(this.options.productOtherFileUrls,'this.options.productOtherFileUrls')

        // this.faQuotation.productName = this.faQuotation[this.plangJava('productName')]
        // this.faQuotation.address = this.faQuotation[this.plangJava('address')]
        // this.faQuotation.description = this.faQuotation[this.plangJava('description')]
        // this.faQuotation.productBrand = this.faQuotation[this.plangJava('productBrand')]

				console.log('this.faQuotation==',        this.faQuotation.address, this.faQuotation)
			}
		})
	},
    confirmUnit(e) {
		console.log('e', e)
		this.priceUnit = e[0].label
		this.faQuotation.currency = e[0].value 
		this.isShowUnit = false
    },
   
	// 提交{{$t('参与订单')}}
    onSubmit() {
		this.validateFlag= true
		for(let i=0;i<this.options.productImgUrls.length;i++){
			if(i>0){
				this.faQuotation.productImgUrls+=(","+this.options.productImgUrls[i].fullurl)
			}else{
				this.faQuotation.productImgUrls=""+this.options.productImgUrls[i].fullurl
			}
		}
		
		for(let i=0;i<this.options.accountNumberImg.length;i++){
			if(i>0){
				this.faQuotation.accountNumberImg+=(","+this.options.accountNumberImg[i].fullurl)
			}else{
				this.faQuotation.accountNumberImg=""+this.options.accountNumberImg[i].fullurl
			}
		}
		for(let i=0;i<this.options.productOtherFileUrls.length;i++){
			if(i>0){
				this.faQuotation.productOtherFileUrls+=(","+this.options.productOtherFileUrls[i].fullurl)
			}else{
				this.faQuotation.productOtherFileUrls=""+this.options.productOtherFileUrls[i].fullurl
			}
		}
		
		for(let i=0;i<this.options.productVideoUrls.length;i++){
			this.faQuotation.productVideoUrls=""+this.options.productVideoUrls[i].fullurl
		}
		console.log('purchaseInfo---', this.purchaseInfo)
		this.faQuotation.userId = uni.getStorageSync('user_id')
		this.faQuotation.purchaseInfoId = this.purchaseInfo.purchaseInfo.id
		console.log('this.faQuotation---', this.faQuotation)
		// return
		console.log('this.currentType--', this.currentType)
		if(this.currentType == 1 && !this.faQuotation.productName) return
		if(this.currentType == 1 && !this.faQuotation.productBrand) return
		if(!this.faQuotation.price) return
		if(!this.priceUnit) return
		// if(!this.faQuotation.ruble) return
		if(!this.faQuotation.address) return
		if(!this.faQuotation.productDuration) return
		if(!this.faQuotation.description) return
		// if(this.currentType == 2 && this.options.accountNumberImg.length == 0) return
		// if(this.options.accountNumberImg.length == 0) return

		if(!this.faQuotation.productImgUrls) return

		if (this.currentType == 2 && this.shopProduct.length == 0 ) return
		if (this.qutationId) {
			this.faQuotation.id = this.qutationId
			delete this.faQuotation.createTime
			console.log('888888', this.faQuotation)
		}
		console.log('9999999', this.faQuotation)
		uni.showLoading({
			title: this.$t('加载中')
		});

		faQuotationSave({
      ...this.faQuotation,
      isOptionGood: this.currentType, // 1填写商品  2选择商品
    }).then(res => {
			console.log('res-----', res)
			if(res.code == 0) {
				// uni.$u.toast(res[this.plang('msg')])
        uni.$u.toast(this.$t('提交成功'))
        setTimeout(()=>{
          uni.navigateBack()
        },1000)
				
			} else {
				// uni.$u.toast(res.msg)
        // uni.$u.toast(res[this.plang('msg')])
        uni.$u.toast(this.$t('提交失败'))
				this.btnDis = false
			}
			uni.hideLoading()
		})
		// uni.redirectTo({
		//   url:'/pages/caigou/success/index',
		// })
		
      // uni.navigateBack({
      //   delta: 1,
      // })
    },
  
  },
}

</script>



<style lang="scss" scoped>
	@import '@/assets/appScss.scss';
@import './index.scss';
</style>


<style>
.input-placeholder-cai {
  color: #606366;
  font-size: 26rpx;
}
.scroll-wrapper .bottom-form .upload-wrapper .upload-li .uploads .img.zhan{
  overflow: visible;
  border-radius: 12rpx;
          .paly {
            width: 50rpx;
            height: 50rpx;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%,-50%);
          }
}
.swiper {
    height: 100%;

    .img,
    .video_wrap {
      height: 100%;
    }

    .video-wrapxx {
      height: 100%;
      width: 100%;
      

      image {
        width: 100%;
        height: 100%;
      }
    }

    .play_wrap {
      width: 100%;
      height: 75%;
      z-index: 222;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      display: flex;
      align-items: center;
      justify-content: center;
    }



    .icon_wrap {
      width: 100rpx;
      height: 100rpx;
      text-align: center;
      padding-top: 28rpx;
      background: rgba(217, 217, 217, 0.6);
      border-radius: 100%;

      .u-icon--right {
        padding-left: 8rpx;
      }
    }
  }
  .palyxxx {
  position: fixed;
  left: -120vw;
}

</style>